
const router = require("express-promise-router")();
const BorrowTimeService = require("../../services/borrow_time");
const LogService = require("../../services/log");


/**
 * @openapi
 * /teacher/borrow_time/add:
 *   post:
 *     tags:
 *     - borrow_time
 *     summary: 创建名单
 *     requestBody:
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               name:
 *                 type: string
 *               usernames:
 *                  type: array
 *                  items:
 *                      type: string
 *       required: true
 *     responses:
 *       200:
 *         description: 返回创建的名单
 */
router.post('/add', async function(req, res) {
    let schedule=req.body;
    const result=await BorrowTimeService.add(schedule);
    return res.json(result);
});

/**
 * @openapi
 * /teacher/borrow_time/remove:
 *   post:
 *     tags:
 *     - borrow_time
 *     summary: 删除名单
 *     requestBody:
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               id:
 *                 type: string
 *       required: true
 *     responses:
 *       200:
 *         description: 返回创建的名单
 */
router.post('/remove', async function(req, res) {
    let {scheduleId}=req.body;
    console.log('scheduleId',scheduleId)
    const result=await BorrowTimeService.remove(scheduleId);
    return res.json(result);
});



/**
 * @openapi
 * /teacher/borrow_time/update  :
 *   get:
 *     tags:
 *     - borrow_time
 *     summary: 更新
 *     requestBody:
 *     responses:
 *       200:
 *         description: 返回修改的名单
 */
router.post('/update', async function(req, res) {
    let {scheduleId,schedule}=req.body;
    const result=await BorrowTimeService.update(scheduleId,schedule);
    return res.json(result);
});




module.exports = router;